package com.yayan.xh.service;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;

import com.yayan.xh.bean.ImageBean;
import com.yayan.xh.dao.IImageDao;
import com.yayan.xh.dao.ImageDao;

@Service
public class ImagesService implements IImageService {
	
	private IImageDao imageDao;
	
	public ImagesService() {
		imageDao = new ImageDao();
	}

	@Override
	public List<ImageBean> getImageByMatchIdBack(Map<String, String> map) {
		List<ImageBean> list = null;
		try {
			list = imageDao.getImageByMatchIdBack(map);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return list;
	}

	@Override
	public boolean saveImageBack(Map<String, String> map) {
		boolean f = false;
		try {
			if(null != map.get("matchId") && null != map.get("image") 
					&& !"0".equalsIgnoreCase(map.get("matchId")) && !"0".equalsIgnoreCase(map.get("image"))) {
				f = imageDao.saveImage(map);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return f;
	}

	@Override
	public boolean delImageBack(Map<String, String> map) {
		boolean f = false;
		try {
			if(null != map.get("id") && !"0".equalsIgnoreCase(map.get("id"))) {
				f = imageDao.delImage(map);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return f;
	}

	@Override
	public ImageBean getImageByIdBack(Map<String, String> map) {
		ImageBean bean = null;
		try {
			bean = imageDao.getImageByIdBack(map);
		} catch (Exception e) {
			// TODO: handle exception
		}
		return bean;
	}

}
